package com.dao.system;

import org.hibernate.Query;
import org.hibernate.Session;
import org.junit.Before;
import org.junit.Test;

import com.hibernate.SystemHibernateSessionFactory;
import com.pojo.system.PSWDPk;

public class TestPSWDDao {
	
	private Session session;
	private PSWDPk pswdPk;
	
	
	@Before
	public void init(){
		session  =  SystemHibernateSessionFactory.getSession();
		pswdPk = new PSWDPk();
		pswdPk.setCompno("0001");
		pswdPk.setUsr("GT0037");
	}
	
	@Test
	public void getSession(){
		//PSWD pswd = (PSWD) session.get(PSWD.class, pswdPk);
		//System.out.println(pswd.getName());
		//org.junit.Assert.assertTrue(pswd.getId().getUsr().equals("GT0037"));
		String compNo = "0001";
		Query query = session.createQuery("from PSWD as pswd where pswd.id.usr='GT0037' and pswd.id.compno='"+compNo+"'");
		org.junit.Assert.assertTrue(query.list().size()>0);
	}
}
